import 'package:date_format/date_format.dart';
import 'package:flutter/material.dart';
import 'package:fwanandroid/model/bean/Article.dart';

class ProjectArticleItemWidget extends StatelessWidget {

  Article article;

  ProjectArticleItemWidget({super.key,required this.article});

  @override
  Widget build(BuildContext context) {
    return Padding(
        padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
        child: Row(
          children: [
            Image.network(
              article.envelopePic,
              width: 120,
              height: 200,
            ),
            SizedBox(
              width: 8,
            ),
            SizedBox(
              width: MediaQuery.of(context).size.width - 160,
              height: 200,
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    "${article.title}",
                    style: TextStyle(color: Colors.black, fontSize: 14),
                  ),
                  Expanded(
                    flex: 1,
                    child: Text(
                      "${article.desc}",
                      style: TextStyle(color: Colors.grey, fontSize: 12),
                    ),
                  ),
                  Row(
                    children: [
                      Text(
                        "${formatDate(DateTime.fromMillisecondsSinceEpoch(article.publishTime.toInt()), [
                          yyyy,
                          '-',
                          mm,
                          '-',
                          dd,
                          ' ',
                          HH,
                          ':',
                          nn
                        ])}",
                        style: TextStyle(color: Colors.grey, fontSize: 12),
                      ),
                      SizedBox(
                        width: 8,
                      ),
                      Expanded(
                        flex: 1,
                        child: Text("${article.author}",
                            maxLines: 1,
                            overflow: TextOverflow.ellipsis,
                            style: TextStyle(color: Colors.grey, fontSize: 12)),
                      ),
                      SizedBox(
                        width: 8,
                      ),
                      Image.asset(
                        "assets/images/timeline_like_normal.png",
                        width: 12,
                        height: 12,
                      )
                    ],
                  )
                ],
              ),
            )
          ],
        ));
  }
}
